class MaxQueue {
public:
    MaxQueue() {}
    
    int max_value() {
        return _maxQueue.empty()?-1:_maxQueue.front();
    }
    
    void push_back(int value) {
        _Queue.push(value);
        //deque保持非递减序列
        while(!_maxQueue.empty()&&value>_maxQueue.back())
        {
            _maxQueue.pop_back();
        }
        _maxQueue.push_back(value);
    }
    
    int pop_front() {
        if(_Queue.empty())
        {
            return -1;
        }
        int res=_Queue.front();
        _Queue.pop();
        //保持deque同步pop
        if(res==_maxQueue.front())
        {
            _maxQueue.pop_front();
        }
        return res;
    }
private:
    queue<int>_Queue;
    deque<int>_maxQueue;
};

/**
 * Your MaxQueue object will be instantiated and called as such:
 * MaxQueue* obj = new MaxQueue();
 * int param_1 = obj->max_value();
 * obj->push_back(value);
 * int param_3 = obj->pop_front();
 */